<?php

/**
 * XHTML Document, Head > Stylesheet
 * 
 * @package Core
 * @subpackage Document
 *
 */
class Lead_Controller_Response_Document_Head_Style extends Lead_Controller_Response_Document_Head_Part 
{
	
	/**
	 * Stylesheet types (0 => stylesheet, 1 => alternate stylesheet)
	 *
	 * @var unknown_type
	 */
	protected $styletypes = array(0 => 'stylesheet', 1 => 'alternate stylesheet');
	/**
	 * Style data
	 *
	 * @var array
	 */
	protected $styles = array();
	
	private $_defaultStyle = array('alternate' => '0', 'media' => 'all');
	
				
	/**
	 * Adds a stylesheet
	 *
	 * @param string $value Stylesheet URI
	 * @param integer $alternate 0 for stylesheet, 1 for alternate
	 */
	function add($value, $config = array())
	{
		
		$sArr = array_merge($this->_defaultStyle, array('value' => $value), $config);
	
	    $this->styles[] = $sArr;
	}
	
	
	/**
	 * Renders stylesheets
	 *
	 * @return string
	 */
	function render()
	{
		$output = array();
		foreach($this->styles as $stylekey => &$stylevalue)
		{
		    $output[] = "<link rel=\"{$this->styletypes[$stylevalue['alternate']]}\" type=\"text/css\" href=\"{$stylevalue['value']}\" media=\"{$stylevalue['media']}\" />";
		}

		return implode("\n", $output);
		
	}
	
	
	
	
}
?>